var _gl = window._gl || {};
_gl.environment = "production";
_gl._host_api = "http://friday.admin.elmi.cn/api";
/*!
 * iCheck v1.0.1, http://git.io/arlzeA
 * ===================================
 * Powerful jQuery and Zepto plugin for checkboxes and radio buttons customization
 *
 * (c) 2013 Damir Sultanov, http://fronteed.com
 * MIT Licensed
 */
//checkbox radio插件
;(function($) {

    // Cached vars
    var _iCheck = 'iCheck',
        _iCheckHelper = _iCheck + '-helper',
        _checkbox = 'checkbox',
        _radio = 'radio',
        _checked = 'checked',
        _unchecked = 'un' + _checked,
        _disabled = 'disabled',a
    _determinate = 'determinate',
        _indeterminate = 'in' + _determinate,
        _update = 'update',
        _type = 'type',
        _click = 'click',
        _touch = 'touchbegin.i touchend.i',
        _add = 'addClass',
        _remove = 'removeClass',
        _callback = 'trigger',
        _label = 'label',
        _cursor = 'cursor',
        _mobile = /ipad|iphone|ipod|android|blackberry|windows phone|opera mini|silk/i.test(navigator.userAgent);

    // Plugin init
    $.fn[_iCheck] = function(options, fire) {

        // Walker
        var handle = 'input[type="' + _checkbox + '"], input[type="' + _radio + '"]',
            stack = $(),
            walker = function(object) {
                object.each(function() {
                    var self = $(this);

                    if (self.is(handle)) {
                        stack = stack.add(self);
                    } else {
                        stack = stack.add(self.find(handle));
                    }
                });
            };

        // Check if we should operate with some method
        if (/^(check|uncheck|toggle|indeterminate|determinate|disable|enable|update|destroy)$/i.test(options)) {

            // Normalize method's name
            options = options.toLowerCase();

            // Find checkboxes and radio buttons
            walker(this);

            return stack.each(function() {
                var self = $(this);

                if (options == 'destroy') {
                    tidy(self, 'ifDestroyed');
                } else {
                    operate(self, true, options);
                }

                // Fire method's callback
                if ($.isFunction(fire)) {
                    fire();
                }
            });

            // Customization
        } else if (typeof options == 'object' || !options) {

            // Check if any options were passed
            var settings = $.extend({
                    checkedClass: _checked,
                    disabledClass: _disabled,
                    indeterminateClass: _indeterminate,
                    labelHover: true
                }, options),

                selector = settings.handle,
                hoverClass = settings.hoverClass || 'hover',
                focusClass = settings.focusClass || 'focus',
                activeClass = settings.activeClass || 'active',
                labelHover = !!settings.labelHover,
                labelHoverClass = settings.labelHoverClass || 'hover',

            // Setup clickable area
                area = ('' + settings.increaseArea).replace('%', '') | 0;

            // Selector limit
            if (selector == _checkbox || selector == _radio) {
                handle = 'input[type="' + selector + '"]';
            }

            // Clickable area limit
            if (area < -50) {
                area = -50;
            }

            // Walk around the selector
            walker(this);

            return stack.each(function() {
                var self = $(this);

                // If already customized
                tidy(self);

                var node = this,
                    id = node.id,

                // Layer styles
                    offset = -area + '%',
                    size = 100 + (area * 2) + '%',
                    layer = {
                        position: 'absolute',
                        top: offset,
                        left: offset,
                        display: 'block',
                        width: size,
                        height: size,
                        margin: 0,
                        padding: 0,
                        background: '#fff',
                        border: 0,
                        opacity: 0
                    },

                // Choose how to hide input
                    hide = _mobile ? {
                        position: 'absolute',
                        visibility: 'hidden'
                    } : area ? layer : {
                        position: 'absolute',
                        opacity: 0
                    },

                // Get proper class
                    className = node[_type] == _checkbox ? settings.checkboxClass || 'i' + _checkbox : settings.radioClass || 'i' + _radio,

                // Find assigned labels
                    label = $(_label + '[for="' + id + '"]').add(self.closest(_label)),

                // Check ARIA option
                    aria = !!settings.aria,

                // Set ARIA placeholder
                    ariaID = _iCheck + '-' + Math.random().toString(36).substr(2,6),

                // Parent & helper
                    parent = '<div class="' + className + '" ' + (aria ? 'role="' + node[_type] + '" ' : ''),
                    helper;

                // Set ARIA "labelledby"
                if (aria) {
                    label.each(function() {
                        parent += 'aria-labelledby="';

                        if (this.id) {
                            parent += this.id;
                        } else {
                            this.id = ariaID;
                            parent += ariaID;
                        }

                        parent += '"';
                    });
                }

                // Wrap input
                parent = self.wrap(parent + '/>')[_callback]('ifCreated').parent().append(settings.insert);

                // Layer addition
                helper = $('<ins class="' + _iCheckHelper + '"/>').css(layer).appendTo(parent);

                // Finalize customization
                self.data(_iCheck, {o: settings, s: self.attr('style')}).css(hide);
                !!settings.inheritClass && parent[_add](node.className || '');
                !!settings.inheritID && id && parent.attr('id', _iCheck + '-' + id);
                parent.css('position') == 'static' && parent.css('position', 'relative');
                operate(self, true, _update);

                // Label events
                if (label.length) {
                    label.on(_click + '.i mouseover.i mouseout.i ' + _touch, function(event) {
                        var type = event[_type],
                            item = $(this);

                        // Do nothing if input is disabled
                        if (!node[_disabled]) {

                            // Click
                            if (type == _click) {
                                if ($(event.target).is('a')) {
                                    return;
                                }
                                operate(self, false, true);

                                // Hover state
                            } else if (labelHover) {

                                // mouseout|touchend
                                if (/ut|nd/.test(type)) {
                                    parent[_remove](hoverClass);
                                    item[_remove](labelHoverClass);
                                } else {
                                    parent[_add](hoverClass);
                                    item[_add](labelHoverClass);
                                }
                            }

                            if (_mobile) {
                                event.stopPropagation();
                            } else {
                                return false;
                            }
                        }
                    });
                }

                // Input events
                self.on(_click + '.i focus.i blur.i keyup.i keydown.i keypress.i', function(event) {
                    var type = event[_type],
                        key = event.keyCode;

                    // Click
                    if (type == _click) {
                        return false;

                        // Keydown
                    } else if (type == 'keydown' && key == 32) {
                        if (!(node[_type] == _radio && node[_checked])) {
                            if (node[_checked]) {
                                off(self, _checked);
                            } else {
                                on(self, _checked);
                            }
                        }

                        return false;

                        // Keyup
                    } else if (type == 'keyup' && node[_type] == _radio) {
                        !node[_checked] && on(self, _checked);

                        // Focus/blur
                    } else if (/us|ur/.test(type)) {
                        parent[type == 'blur' ? _remove : _add](focusClass);
                    }
                });

                // Helper events
                helper.on(_click + ' mousedown mouseup mouseover mouseout ' + _touch, function(event) {
                    var type = event[_type],

                    // mousedown|mouseup
                        toggle = /wn|up/.test(type) ? activeClass : hoverClass;

                    // Do nothing if input is disabled
                    if (!node[_disabled]) {

                        // Click
                        if (type == _click) {
                            operate(self, false, true);

                            // Active and hover states
                        } else {

                            // State is on
                            if (/wn|er|in/.test(type)) {

                                // mousedown|mouseover|touchbegin
                                parent[_add](toggle);

                                // State is off
                            } else {
                                parent[_remove](toggle + ' ' + activeClass);
                            }

                            // Label hover
                            if (label.length && labelHover && toggle == hoverClass) {

                                // mouseout|touchend
                                label[/ut|nd/.test(type) ? _remove : _add](labelHoverClass);
                            }
                        }

                        if (_mobile) {
                            event.stopPropagation();
                        } else {
                            return false;
                        }
                    }
                });
            });
        } else {
            return this;
        }
    };

    // Do something with inputs
    function operate(input, direct, method) {
        var node = input[0],
            state = /er/.test(method) ? _indeterminate : /bl/.test(method) ? _disabled : _checked,
            active = method == _update ? {
                checked: node[_checked],
                disabled: node[_disabled],
                indeterminate: input.attr(_indeterminate) == 'true' || input.attr(_determinate) == 'false'
            } : node[state];

        // Check, disable or indeterminate
        if (/^(ch|di|in)/.test(method) && !active) {
            on(input, state);

            // Uncheck, enable or determinate
        } else if (/^(un|en|de)/.test(method) && active) {
            off(input, state);

            // Update
        } else if (method == _update) {

            // Handle states
            for (var each in active) {
                if (active[each]) {
                    on(input, each, true);
                } else {
                    off(input, each, true);
                }
            }

        } else if (!direct || method == 'toggle') {

            // Helper or label was clicked
            if (!direct) {
                input[_callback]('ifClicked');
            }

            // Toggle checked state
            if (active) {
                if (node[_type] !== _radio) {
                    off(input, state);
                }
            } else {
                on(input, state);
            }
        }
    }

    // Add checked, disabled or indeterminate state
    function on(input, state, keep) {
        var node = input[0],
            parent = input.parent(),
            checked = state == _checked,
            indeterminate = state == _indeterminate,
            disabled = state == _disabled,
            callback = indeterminate ? _determinate : checked ? _unchecked : 'enabled',
            regular = option(input, callback + capitalize(node[_type])),
            specific = option(input, state + capitalize(node[_type]));

        // Prevent unnecessary actions
        if (node[state] !== true) {

            // Toggle assigned radio buttons
            if (!keep && state == _checked && node[_type] == _radio && node.name) {
                var form = input.closest('form'),
                    inputs = 'input[name="' + node.name + '"]';

                inputs = form.length ? form.find(inputs) : $(inputs);

                inputs.each(function() {
                    if (this !== node && $(this).data(_iCheck)) {
                        off($(this), state);
                    }
                });
            }

            // Indeterminate state
            if (indeterminate) {

                // Add indeterminate state
                node[state] = true;

                // Remove checked state
                if (node[_checked]) {
                    off(input, _checked, 'force');
                }

                // Checked or disabled state
            } else {

                // Add checked or disabled state
                if (!keep) {
                    node[state] = true;
                }

                // Remove indeterminate state
                if (checked && node[_indeterminate]) {
                    off(input, _indeterminate, false);
                }
            }

            // Trigger callbacks
            callbacks(input, checked, state, keep);
        }

        // Add proper cursor
        if (node[_disabled] && !!option(input, _cursor, true)) {
            parent.find('.' + _iCheckHelper).css(_cursor, 'default');
        }

        // Add state class
        parent[_add](specific || option(input, state) || '');

        // Set ARIA attribute
        if (!!parent.attr('role') && !indeterminate) {
            parent.attr('aria-' + (disabled ? _disabled : _checked), 'true');
        }

        // Remove regular state class
        parent[_remove](regular || option(input, callback) || '');
    }

    // Remove checked, disabled or indeterminate state
    function off(input, state, keep) {
        var node = input[0],
            parent = input.parent(),
            checked = state == _checked,
            indeterminate = state == _indeterminate,
            disabled = state == _disabled,
            callback = indeterminate ? _determinate : checked ? _unchecked : 'enabled',
            regular = option(input, callback + capitalize(node[_type])),
            specific = option(input, state + capitalize(node[_type]));

        // Prevent unnecessary actions
        if (node[state] !== false) {

            // Toggle state
            if (indeterminate || !keep || keep == 'force') {
                node[state] = false;
            }

            // Trigger callbacks
            callbacks(input, checked, callback, keep);
        }

        // Add proper cursor
        if (!node[_disabled] && !!option(input, _cursor, true)) {
            parent.find('.' + _iCheckHelper).css(_cursor, 'pointer');
        }

        // Remove state class
        parent[_remove](specific || option(input, state) || '');

        // Set ARIA attribute
        if (!!parent.attr('role') && !indeterminate) {
            parent.attr('aria-' + (disabled ? _disabled : _checked), 'false');
        }

        // Add regular state class
        parent[_add](regular || option(input, callback) || '');
    }

    // Remove all traces
    function tidy(input, callback) {
        if (input.data(_iCheck)) {

            // Remove everything except input
            input.parent().html(input.attr('style', input.data(_iCheck).s || ''));

            // Callback
            if (callback) {
                input[_callback](callback);
            }

            // Unbind events
            input.off('.i').unwrap();
            $(_label + '[for="' + input[0].id + '"]').add(input.closest(_label)).off('.i');
        }
    }

    // Get some option
    function option(input, state, regular) {
        if (input.data(_iCheck)) {
            return input.data(_iCheck).o[state + (regular ? '' : 'Class')];
        }
    }

    // Capitalize some string
    function capitalize(string) {
        return string.charAt(0).toUpperCase() + string.slice(1);
    }

    // Executable handlers
    function callbacks(input, checked, callback, keep) {
        if (!keep) {
            if (checked) {
                input[_callback]('ifToggled');
            }

            input[_callback]('ifChanged')[_callback]('if' + capitalize(callback));
        }
    }
})(window.jQuery || window.Zepto);

+(function() {
    'use strict';
    var s = function(e, f) {
        var n = this;
        var g = {
            container: e,
            width: 300,
            height: 200,
            sources: [],
            type: "flip"
        };
        var h = null;
        var i = null;
        var j = 0;
        f = f || {};
        var k = {};
        for (var l in f) {
            if (typeof f[l] === 'object') {
                k[l] = {};
                for (var m in f[l]) {
                    k[l][m] = f[l][m]
                }
            } else {
                k[l] = f[l]
            }
        }
        ;for (var o in g) {
            if (typeof f[o] === 'object') {
                for (var p in g[o]) {
                    if (typeof f[o][p] === 'undefined') {
                        f[o][p] = g[o][p]
                    }
                }
            } else if (typeof f[o] === 'undefined') {
                f[o] = g[o]
            }
        }
        ;n.params = f;
        n.originParams = k;
        var q = function(a, b, c, d) {
            if (a.addEventListener) {
                a.addEventListener(b, c, d)
            } else if (a.attachEvent) {
                a.attach("on" + b, c)
            }
        };
        var r = function() {
            i = document.querySelector(n.params.container);
            n.iContainer = i;
            h = document.createElement("div");
            n.iWrapper = h;
            if (i != null) {
                i.style.width = n.params.width + "px";
                i.style.height = n.params.height + "px";
                h.style.width = n.params.width + "px";
                h.style.height = n.params.height + "px";
                h.style.position = "absolute";
                h.style.top = "0";
                h.style.left = "0";
                h.style.background = "url(" + n.params.sources[j] + ") 0px 0px no-repeat";
                h.style.backgroundSize = n.params.width + "px " + window.innerHeight + "px";
                i.appendChild(h)
            }
            n.lock = true
        };
        r();
        return n
    };
    s.prototype = {
        activeIndex: 0,
        animate: function(b, c, d) {
            var e = {};
            var a = 0;
            clearInterval(b.timer);
            b.timer = setInterval(function() {
                e["x"] = (a += 6);
                if (c)
                    c.call(b, e);
                if (e["x"] == 180) {
                    clearInterval(b.timer);
                    if (d)
                        d.call(b)
                }
            }, 30)
        },
        flip: function() {
            var n = this;
            var e = n.params.sources[n.activeIndex];
            if (!n.lock)
                return;
            n.lock = false;
            n.iWrapper.style.background = 'none';
            n.iWrapper.innerHTML = "";
            var R = 6;
            var C = 3;
            var f = R * C;
            for (var i = 0; i < C; i++) {
                for (var j = 0; j < R; j++) {
                    var g = Math.ceil(n.params.width / C) * i;
                    var h = Math.ceil(n.params.height / R) * j;
                    var k = document.createElement("div");
                    k.className = "flip";
                    k.style.background = "url(" + e + ") -" + g + "px -" + h + "px no-repeat";
                    k.style.backgroundSize = n.params.width + "px " + window.innerHeight + "px";
                    k.style.width = Math.ceil(n.params.width / C) + "px";
                    k.style.height = Math.ceil(n.params.height / R) + "px";
                    k.style.position = "absolute";
                    k.style.left = g + "px";
                    k.style.top = h + "px";
                    (function(b, c, d) {
                        b.change = false;
                        setTimeout(function() {
                            n.animate(b, function(a) {
                                if (a.x > 90 && !b.change) {
                                    b.style.background = "url(" + n.params.sources[n.next()] + ") -" + c + "px -" + d + "px no-repeat";
                                    b.style.backgroundSize = n.params.width + "px " + window.innerHeight + "px"
                                }
                                if (a.x > 90) {
                                    b.style.transform = "perspective(500px) rotateY(" + a.x + "deg) scale(-1, 1)"
                                } else {
                                    b.style.transform = "perspective(500px) rotateY(" + a.x + "deg)"
                                }
                            }, function() {
                                if ((--f) == 0) {
                                    n.activeIndex = n.next();
                                    n.lock = true
                                }
                            })
                        }, (i + j) * 200)
                    })(k, g, h);
                    n.iWrapper.appendChild(k);
                    k = null
                }
            }
        },
        next: function() {
            var n = this;
            return (n.activeIndex + 1) % n.params.sources.length
        }
    };
    window.NSlide = s
})();

var _store = (function(window) {
    // Store.js
    var store = {},
        win = (typeof window != 'undefined' ? window : global),
        doc = win.document,
        localStorageName = 'localStorage',
        scriptTag = 'script',
        storage

    store.disabled = false
    store.version = '1.3.20'
    store.set = function(key, value) {}
    store.get = function(key, defaultVal) {}
    store.has = function(key) { return store.get(key) !== undefined }
    store.remove = function(key) {}
    store.clear = function() {}
    store.transact = function(key, defaultVal, transactionFn) {
        if (transactionFn == null) {
            transactionFn = defaultVal
            defaultVal = null
        }
        if (defaultVal == null) {
            defaultVal = {}
        }
        var val = store.get(key, defaultVal)
        transactionFn(val)
        store.set(key, val)
    }
    store.getAll = function() {
        var ret = {}
        store.forEach(function(key, val) {
            ret[key] = val
        })
        return ret
    }
    store.forEach = function() {}
    store.serialize = function(value) {
        return JSON.stringify(value)
    }
    store.deserialize = function(value) {
        if (typeof value != 'string') { return undefined }
        try { return JSON.parse(value) }
        catch(e) { return value || undefined }
    }

    // Functions to encapsulate questionable FireFox 3.6.13 behavior
    // when about.config::dom.storage.enabled === false
    // See https://github.com/marcuswestin/store.js/issues#issue/13
    function isLocalStorageNameSupported() {
        try { return (localStorageName in win && win[localStorageName]) }
        catch(err) { return false }
    }

    if (isLocalStorageNameSupported()) {
        storage = win[localStorageName]
        store.set = function(key, val) {
            if (val === undefined) { return store.remove(key) }
            storage.setItem(key, store.serialize(val))
            return val
        }
        store.get = function(key, defaultVal) {
            var val = store.deserialize(storage.getItem(key))
            return (val === undefined ? defaultVal : val)
        }
        store.remove = function(key) { storage.removeItem(key) }
        store.clear = function() { storage.clear() }
        store.forEach = function(callback) {
            for (var i=0; i<storage.length; i++) {
                var key = storage.key(i)
                callback(key, store.get(key))
            }
        }
    } else if (doc && doc.documentElement.addBehavior) {
        var storageOwner,
            storageContainer
        // Since #userData storage applies only to specific paths, we need to
        // somehow link our data to a specific path.  We choose /favicon.ico
        // as a pretty safe option, since all browsers already make a request to
        // this URL anyway and being a 404 will not hurt us here.  We wrap an
        // iframe pointing to the favicon in an ActiveXObject(htmlfile) object
        // (see: http://msdn.microsoft.com/en-us/library/aa752574(v=VS.85).aspx)
        // since the iframe access rules appear to allow direct access and
        // manipulation of the document element, even for a 404 page.  This
        // document can be used instead of the current document (which would
        // have been limited to the current path) to perform #userData storage.
        try {
            storageContainer = new ActiveXObject('htmlfile')
            storageContainer.open()
            storageContainer.write('<'+scriptTag+'>document.w=window</'+scriptTag+'><iframe src="/favicon.ico"></iframe>')
            storageContainer.close()
            storageOwner = storageContainer.w.frames[0].document
            storage = storageOwner.createElement('div')
        } catch(e) {
            // somehow ActiveXObject instantiation failed (perhaps some special
            // security settings or otherwse), fall back to per-path storage
            storage = doc.createElement('div')
            storageOwner = doc.body
        }
        var withIEStorage = function(storeFunction) {
            return function() {
                var args = Array.prototype.slice.call(arguments, 0)
                args.unshift(storage)
                // See http://msdn.microsoft.com/en-us/library/ms531081(v=VS.85).aspx
                // and http://msdn.microsoft.com/en-us/library/ms531424(v=VS.85).aspx
                storageOwner.appendChild(storage)
                storage.addBehavior('#default#userData')
                storage.load(localStorageName)
                var result = storeFunction.apply(store, args)
                storageOwner.removeChild(storage)
                return result
            }
        }

        // In IE7, keys cannot start with a digit or contain certain chars.
        // See https://github.com/marcuswestin/store.js/issues/40
        // See https://github.com/marcuswestin/store.js/issues/83
        var forbiddenCharsRegex = new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]", "g")
        var ieKeyFix = function(key) {
            return key.replace(/^d/, '___$&').replace(forbiddenCharsRegex, '___')
        }
        store.set = withIEStorage(function(storage, key, val) {
            key = ieKeyFix(key)
            if (val === undefined) { return store.remove(key) }
            storage.setAttribute(key, store.serialize(val))
            storage.save(localStorageName)
            return val
        })
        store.get = withIEStorage(function(storage, key, defaultVal) {
            key = ieKeyFix(key)
            var val = store.deserialize(storage.getAttribute(key))
            return (val === undefined ? defaultVal : val)
        })
        store.remove = withIEStorage(function(storage, key) {
            key = ieKeyFix(key)
            storage.removeAttribute(key)
            storage.save(localStorageName)
        })
        store.clear = withIEStorage(function(storage) {
            var attributes = storage.XMLDocument.documentElement.attributes
            storage.load(localStorageName)
            for (var i=attributes.length-1; i>=0; i--) {
                storage.removeAttribute(attributes[i].name)
            }
            storage.save(localStorageName)
        })
        store.forEach = withIEStorage(function(storage, callback) {
            var attributes = storage.XMLDocument.documentElement.attributes
            for (var i=0, attr; attr=attributes[i]; ++i) {
                callback(attr.name, store.deserialize(storage.getAttribute(attr.name)))
            }
        })
    }

    try {
        var testKey = '__storejs__'
        store.set(testKey, testKey)
        if (store.get(testKey) != testKey) { store.disabled = true }
        store.remove(testKey)
    } catch(e) {
        store.disabled = true
    }
    store.enabled = !store.disabled

    return store
})(window);

var _helper = (function(){
    //获取url参数并放到数组中
    function getRequest(url) {
        if(!url) url = location.search; //获取url中"?"符后的字串
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            strs = str.split("&");
            for (var i = 0, i1 = strs.length; i < i1; i++) {
                theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
            }
        }
        return theRequest;
    }
    //获取表单参数
    function getParameter(id,hasValue){
        var arr = $("#"+id).serializeArray();
        var obj={};
        jQuery.each( arr, function(i, field){
            if(hasValue){
                if(field.value!=""){
                    obj[field.name] = field.value;
                }
            }else{
                obj[field.name] = field.value;
            }
        });
        return obj;
    }

    //获取当天日期
    function getCurrentDate(sep){
        if(!sep && typeof (sep) != "string") sep="-";
        var d =new Date();
        var y = d.getFullYear();
        var m = parseInt(d.getMonth()) + 1;
        m = m<10?"0"+m:m;
        var dy = d.getDate();
        dy = dy<10?"0"+dy:dy;
        return y+sep+m+sep+dy;
    }

    //函数节流
    function throttle_duration(method,delay,duration){
        var timer=null, begin=new Date();
        return function(){
            var context=this, args=arguments, current=new Date();
            clearTimeout(timer);
            if(current-begin>=duration){
                method.apply(context,args);
                begin=current;
            }else{
                timer=setTimeout(function(){
                    method.apply(context,args);
                },delay);
            }
        }
    }

    function storeWithExpiration(){
        return {
            set: function(key, val, exp){
                _store.set(key, { val: val, exp: exp || (365 * 24 * 3600 * 1000), time: new Date().getTime(), ver: _gl._version });
            },
            get: function(key){
                var data = _store.get(key);
                if(!data) return null;
                //超过有效期，或js版本号发生变化，则移除数据返回空值
                if(new Date().getTime() - data.time > data.exp || data.ver !== _gl._version) {
                    _store.remove(key);
                    return null;
                }
                return data.val;
            },
            remove:function(key){
                _store.remove(key);
            }
        }
    }

    //显示功能按钮
    function buttonFunInit(obj){
        if(!layer) return false;
        if(!obj) obj = {};
        if(!obj.arr) obj.arr = [];
        var html ='';
        if(obj.arr.length>0){
            for(var a= 0,a1=obj.arr.length;a<a1;a++){
                html+='<button type="button" class="btn btn-success btn-block btn-'+obj.arr[a].class+'" id="btn-'+obj.arr[a].class+'">'+obj.arr[a].text+'</button>';
            }
        }
        var buttonFunInitIndex=null;
        if(html){
            layer.close(obj.index);
            buttonFunInitIndex = layer.open({
                title: '操作按钮',
                move: false,
                offset:  ['0px', $(window).width()-160],
                area: '160px',
                btn:[],
                shade: 0,
                closeBtn: 0,
                content: html,
                success:function(){
                    for(var a= 0,a1=obj.arr.length;a<a1;a++){
                        $("#btn-"+obj.arr[a].class).on("click",{"index":a},function(e){
                            e.stopPropagation();
                            if(obj.arr[e.data.index].callback) obj.arr[e.data.index]["callback"]();
                        });
                    }
                }
            });
        }
        return buttonFunInitIndex;
    }

    //加载动画
    function fridayLoadinFun(text){
        var loadingIndex = layer.open({
            title: false,
            content: text || '数据加载中，请稍后',
            closeBtn:0,
            btn:false,
            icon:16,
            offset: 't'
        });
        return loadingIndex;
    }

    //AJAX提示框
    function ajaxMessage(obj){
        if(!obj) obj={};
        layer.msg((obj.message)||"操作失败！",{time:1500,offset: 't'},function(){
            if(obj.callback && typeof(obj.callback) == "function") obj.callback();
        });
    }

    //AJAX错误提示框
    function ajaxErrorTips(obj){
        if(!obj) obj={};
        layer.open({
            icon:5,
            title: obj.title||'错误提示',
            content: obj.tips||'操作失败，请稍后再试！',
            offset: 't',
            end:function(){
                if(obj.callback && typeof(obj.callback) == "function") obj.callback();
            }
        });
    }

    //时间格式
    function timeFormat(str){
        if(!str) str ="";
        return str.substring(0,19);
    }
    //性别格式
    function sexFormat(str){
        return str=="1"?"男":"女";
    }
    //课程状态
    function statusFormat(bl){
        return bl?"已上架":"未上架";
    }

    return {
        getRequest:getRequest,
        getParameter:getParameter,
        getCurrentDate:getCurrentDate,
        throttle_duration:throttle_duration,
        storeWithExpiration:storeWithExpiration,
        buttonFunInit:buttonFunInit,
        fridayLoadinFun:fridayLoadinFun,
        ajaxMessage:ajaxMessage,
        ajaxErrorTips:ajaxErrorTips,
        timeFormat:timeFormat,
        sexFormat:sexFormat,
        statusFormat:statusFormat
    }
})();

var _server=(function($,_helper){
    var UserInfo_Service=function(){
        var USERID_KEYWORD = 'CurrentUserID';
        var USERINFO_KEYWORD = 'CurrentUserInfo';
        var USERLOGINSTATE_KEYWORD = 'UserHasLogin';
        return {
            setUserId:function(userId){
                _helper.storeWithExpiration().set(USERID_KEYWORD,userId);
            },
            setUserInfo:function(userInfo){
                _helper.storeWithExpiration().set(USERINFO_KEYWORD,userInfo);
            },
            getUserInfo: function () {
                return _helper.storeWithExpiration().get(USERINFO_KEYWORD);
            },
            getUserId:function(){
                return _helper.storeWithExpiration().get(USERID_KEYWORD);
            },
            removeUserInfo:function(){
                _helper.storeWithExpiration().remove(USERINFO_KEYWORD);
                _helper.storeWithExpiration().remove(USERID_KEYWORD);
            },

            setLoginState:function(state){
                _helper.storeWithExpiration().set(USERLOGINSTATE_KEYWORD,state||"logout");
            },
            getLoginState:function(){
                return _helper.storeWithExpiration().get(USERLOGINSTATE_KEYWORD);
            }
        }
    };
    return {
        UserInfo_Service:UserInfo_Service
    }
})(jQuery,_helper);

_fridayTable = (function(_helper){
    var _currentPage = 1;  //当前页码
    var totalPage = 0;     //总页数
    var _pageSize = 10;    //每一页记录数量
    var config = {};       //配置参数

    var formId = "searchForm";

    /*页面按钮 查询 上一页 下一页*/
    $(document).on( 'click','a,button', function (e) {
        e.stopPropagation();
        if($(this).hasClass("btn-search")){
            //头部查询
            searchData();

        }else if($(this).hasClass("btn-more")){
            //头部更多
            var $glyphicon = $(this).find(".glyphicon");
            if($glyphicon.hasClass("glyphicon-chevron-down")){
                $glyphicon.removeClass("glyphicon-chevron-down").addClass("glyphicon-chevron-up");
            }else{
                $glyphicon.removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down");
            }
            $(".query-list").slideToggle();

        }else {
            var $thisP = $(this).parent("li");
            if($thisP.attr("id")=="prevPage"){
                //列表底部的上一页
                if($thisP.hasClass("disabled")){
                    return false;
                }
                if(_currentPage>1) _currentPage--;
                searchData();

            }else if($thisP.attr("id")=="nextPage"){
                //列表底部的下一页
                if($thisP.hasClass("disabled")){
                    return false;
                }
                if(_currentPage<totalPage) _currentPage++;
                searchData();

            }else{

            }
        }
    });

    //跳转到某一页
    $("#gotoPageInput").on("blur",function(e){
        e.stopPropagation();
        goToPage($(this));
    });
    $("#gotoPageInput").on("keyup",function(e){
        e.stopPropagation();
        e = e || window.event;
        if (e.which == 13) {
            goToPage($(this));
        }
    });

    function setGotoInput(num){
        $("#gotoPageInput").attr({"min":1,"max":num});
    }

    function goToPage(thisP){
        thisP = thisP instanceof $ ? thisP : $(thisP);
        var num = thisP.val();

        if(typeof (num) !="number"){
            num = parseInt(num);
        }
        if(num<=0) num=1;
        else if(num>totalPage) num=totalPage;

        _currentPage = num;
        thisP.val(_currentPage);
        searchData();
    }

    //查询
    function searchData(obj){
        if(!obj) obj={};
        if(obj.url) config.url = obj.url;
        var data = _helper.getParameter(obj.formId || "searchForm",true);
        if(!data) data = {};
        data.pageNo = _currentPage;
        data.pageSize = _pageSize;
        var loadingIndex = _helper.fridayLoadinFun();
        //获取数据源
        setTimeout(function(){
            $.ajax({
                type: "GET",
                url:config.url,
                data: data,
                dataType: "json"
            }).done(function(data) {
                if(data && data.code==200){
                    rendTable(data);
                }else{
                    rendTable();
                    _helper.ajaxMessage({"message":(data&&data.message)||"查询失败！"});
                }
            }).fail(function(){
                _helper.ajaxErrorTips({"tips":"数据加载失败，请稍后再试！"});
            }).always(function(){
                layer.close(loadingIndex);
            });
        },ajaxUrl[environment].settimeoutTime);
    }

    //渲染table
    function rendTable(data){
        if(!data) data={};
        var html='';
        var thisCol = null;
        if(data.dataList && data.dataList.length>0){
            for(var a= 0,a1=data.dataList.length;a<a1;a++){
                html+='<tr>';
                thisCol=null;
                for(var b= 0,b1=config.columns.length;b<b1;b++){
                    thisCol = config.columns[b];
                    if(thisCol.renderFun && typeof(thisCol.renderFun) == "function"){
                        html+='<td>'+thisCol.renderFun(data.dataList[a][thisCol.fieldName]||"")+'</td>';
                    }else if(!thisCol.fieldName){
                        if(thisCol.dom=="seq"){
                            html+='<td>'+(a+1+(data.pageNo-1)*data.pageSize)+'<input type="hidden" value="'+data.dataList[a].id+'"></td>';
                        }else {
                            html+='<td>'+thisCol.dom+'</td>'
                        }

                    }else{
                        if(thisCol.formatFun && typeof(thisCol.formatFun) == "function"){
                            html+='<td>'+thisCol.formatFun(data.dataList[a][thisCol.fieldName])+'</td>';
                        }else{
                            html+='<td>'+data.dataList[a][thisCol.fieldName]||""+'</td>'
                        }
                    }
                }
                html+='</tr>';
            }
        }else{
            html='<tr><td colspan="6" class="noData">没有符合要求的数据</td></tr>';
        }
        $(".totalPage").html(data.totalPage||0);
        totalPage = data.totalPage;
        setGotoInput(totalPage);
        $(".pageNo").html(data.pageNo||0);
        _currentPage = data.pageNo||1;
        $("#example tbody").html(html);

        if(data.pageNo<=1){
            $("#prevPage").addClass("disabled");
        }else{
            $("#prevPage").removeClass("disabled");
        }
        if(data.pageNo>=data.totalPage){
            $("#nextPage").addClass("disabled");
        }else{
            $("#nextPage").removeClass("disabled");
        }
    }

    function setTableTr(obj){
        if(!obj) obj={};
        config.url = obj.url;
        config.columns = obj.columns||[];
    }

    return {
        searchData:searchData,
        setTableTr:setTableTr
    }

})(_helper);



$(function(){
    var mainFrameSrc = $(parent.document).find("#mainFrame").attr("src");
    if(mainFrameSrc){
        mainFrameSrc = mainFrameSrc.substring(mainFrameSrc.indexOf("?"));
        _gl._request=_helper.getRequest(mainFrameSrc);
    }

    $.ajaxSetup({
        crossDomain : true,
        timeout:1000*60*10
    });

    //判断登录状态
    var loginState = _server.UserInfo_Service().getLoginState();
    var url = location.href;
    if(loginState != "login" && url.indexOf("login.html")<=-1){
        _server.UserInfo_Service().setLoginState("logout");
        location.href="../views/login.html";
    }
});

//上传控件
(function ($) {
    "use strict";

    $.fn.UploadControl = function (option){
        var $thisUp = this instanceof $ ? this : $(this);
        var fileType = {
            "image":["png","gif","jpg","jpeg","tiff","bmp"],
            "video":["3gpp","mp4","mpeg"],
            "audio":["mp3","m4a"]
        }
        if(!option) option={};
        var defaultTip = option.defaultTip?option.defaultTip:($thisUp.data("tip")||"点击上传文件");
        var type = option.type?option.type:($thisUp.data("type")||"image");
        var changeTitle = option.changeTitle?option.changeTitle:($thisUp.data("changetitle")||"更换文件");
        var accept = type+"/" + fileType[type].join(","+type+"/");


        if(!option.event) option.event="init";
        if(option.event == "showInput"){
            showInput($thisUp);
        }else if(option.event == "showFile"){
            showFile($thisUp,option.url||"");
        }else if(option.event=="init"){
            initDom();
        }

        //初始化dom
        function initDom(){
            if($thisUp.attr("hasInit")) return false;
            var GirdId = Math.random().toFixed(6)*1000000;
            $thisUp.parent().addClass("upload-control")
            $thisUp.wrap('<a class="upload-input" id="upload-input'+GirdId+'"></a>');
            $thisUp.after('<span class="showFileName">'+defaultTip+'</span><span class="fileErrorTip"></span><span class="fileProgress"></span>');
            $thisUp.attr("accept",accept);
            $thisUp.attr("hasInit","true");

            var fileInfoHtml = '';
            if(type=="image"){
                fileInfoHtml='<div class="coverImg upload-fileInfo">\
                <div class="thumbnail conpou-pic">\
                <img src="../../res/images/1.png" alt="...">\
                </div><div class="fileError">该图片不存在</div>\
                <a href="#" class="btn btn-primary btn-change-pic" role="button" style="width:100%;">'+changeTitle+'</a>\
                </div>';
            }else if(type=="video"){
                fileInfoHtml='<div class="video-info upload-fileInfo">\
                <video width="100%" height="180" poster="../../res/media/default_video.png" preload="None" loop="" controls="" x5-video-player-type="h5" x5-video-player-fullscreen="true" webkit-playsinline="">\
                <source src="../../res/media/default_video.mp4" type="video/mp4">\
                </video><div class="fileError">该视频不存在</div>\
                <a href="#" class="btn btn-primary btn-change-video" role="button" style="width:100%;">'+changeTitle+'</a>\
                </div>';
            }else if(type=="audio"){
                fileInfoHtml='<div class="audio-info upload-fileInfo">\
                <audio width="100%" height="auto" preload="None" loop controls><source src="../../res/media/default_video.mp4" type="audio/mpeg"></audio>\
                <div class="fileError">该音频不存在</div>\
                <a href="#" class="btn btn-primary btn-change-video" role="button" style="width:100%;">'+changeTitle+'</a>\
                </div>';
            }
            var $thisPP = $thisUp.parents(".upload-control");
            if($thisPP.find(".upload-fileInfo").length<=0){
                $thisPP.append(fileInfoHtml);

                $thisPP.find(".upload-fileInfo a.btn").on("click",function(e){
                    e.stopPropagation();
                    var $thisInput = $(this).parents(".upload-control").find("input[type='file']");
                    $thisInput.trigger("click");
                    showInput($thisInput);
                });

                $thisUp.on("change",function(){
                    var that = this;
                    var $this = $(this);
                    var filePath=$this.val();
                    var thisType = $this.data("type");
                    if(judgeFileType(filePath,thisType)){
                        $this.siblings(".fileErrorTip").html("").hide();
                        var arr=filePath.split('\\');
                        var fileName=arr[arr.length-1];
                        $this.siblings(".showFileName").html(fileName).show();
                    }else{
                        defaultTip = $this.data("tip")||"点击上传文件";
                        $this.siblings(".showFileName").html("").hide();
                        $this.siblings(".fileErrorTip").html(defaultTip).show();
                        $this.val("");
                        return false
                    }

                    var $thisFile = this.files[0];
                    if($thisFile.size>100*1024*1024){
                        defaultTip = $this.data("tip")||"点击上传文件";
                        $this.siblings(".showFileName").html("").hide();
                        $this.siblings(".fileErrorTip").html(defaultTip).show();
                        $this.parents(".line-item").find(".error-tips").show().find(".text").html("文件大小不能超过100MB");
                        $this.parents(".line-item").find(".limit-tips").hide();
                        $this.val("");
                        return false;
                    }else{
                        $this.parents(".line-item").find(".error-tips").hide();
                        $this.parents(".line-item").find(".limit-tips").show();
                    }
                    var reader = new FileReader();
                    var $thisType="";
                    if(/image/.test($thisFile.type)){
                        reader.readAsDataURL($thisFile);
                        $thisType="image";
                    }else if(/video/.test($thisFile.type)){
                        reader.readAsDataURL($thisFile);
                        $thisType="video";
                    }else if(/audio/.test($thisFile.type)){
                        reader.readAsDataURL($thisFile);
                        $thisType="audio";
                    }else{
                        reader.readAsText($thisFile);
                        $thisType="text";
                    }
                    reader.onerror = function(){
                        console.log("Could noe read file");

                    }
                    reader.onprogress = function(event){
                        if(event.lengthComputable){
                            $(that).siblings(".fileProgress").css("width",(event.loaded/event.total)*100+"%");
                        }
                    }
                    reader.onload=function(){
                        var data={};
                        data.type=$thisType;
                        switch($thisType){
                            case "image":
                                data.url= reader.result;
                                break;
                            case "video":
                            case "audio":
                            case "text":
                                break;
                            default:
                                break;
                        }
                        if(data.url){
                            showFile(that,data.url);
                        }
                    }

                    if(option.callback && typeof(option.callback) =="function") option.callback.call(this);
                });
            }
        }

        //显示input
        function showInput(thisP){
            thisP = thisP instanceof $ ? thisP:$(thisP);
            var $thisPP = thisP.parents(".upload-control");
            $thisPP.find(".upload-fileInfo").hide();
            $thisPP.find(".upload-input").show().find("input[type='file']").val("");
            defaultTip = thisP.data("tip")||"点击上传文件";
            $thisPP.find(".showFileName").html(defaultTip);
            $thisPP.find(".fileerrorTip").html("");
            $thisPP.find(".fileProgress").css("width","0%");

            var videos = $thisPP.find("video,audio");
            if(videos.length>0){
                videos.each(function(){
                    this.pause();
                    this.load();
                });
            }
        }

        //显示文件
        function showFile(thisP,url){
            thisP = thisP instanceof $ ? thisP:$(thisP);
            var $thisPP = thisP.parents(".upload-control");
            var thisType = thisP.data("type");
            if(thisType=="image"){
                var img = new Image();
                img.src = url;
                img.onload=function(){
                    $thisPP.find(".upload-fileInfo").show().find(".thumbnail").show().find("img").attr("src",url||"");
                    $thisPP.find(".upload-fileInfo").find(".fileError").hide();
                }
                img.onerror=function(){
                    //设置错误提示路径
                    url="";
                    $thisPP.find(".upload-fileInfo").show().find(".thumbnail").hide().find("img").attr("src",url||"");
                    $thisPP.find(".upload-fileInfo").find(".fileError").show();
                }

            }else if(thisType=="video"){
                $thisPP.find(".upload-fileInfo").show().find("video").show().find("source").attr("src",url||"");
                $thisPP.find(".upload-fileInfo").find(".fileError").hide();
            }else if(thisType=="audio"){
                $thisPP.find(".upload-fileInfo").show().find("audio").show().find("source").attr("src",url||"");
                $thisPP.find(".upload-fileInfo").find(".fileError").hide();
            }
            $thisPP.find(".upload-input").hide();
        }

        //判断选择的文件类型是否符合要求
        function judgeFileType(path,thisType){
            path = path+"";
            if(path.indexOf("base64")>-1){
                return true;
            }
            var suffix = path?path.substring(path.lastIndexOf(".")+1):"";
            var bl=false;
            for(var a= 0,a1=fileType[thisType].length;a<a1;a++){
                if(fileType[thisType][a] == suffix){
                    bl=true;
                    break;
                }
            }
            return bl;
        }
    }
})(jQuery);